package no.uio.inf5750.wsclient.dao.mockup;

import java.util.Vector;

import no.uio.inf5750.wsclient.dao.DatasetDAO;
import no.uio.inf5750.wsclient.model.DataElement;
import no.uio.inf5750.wsclient.model.DataValue;
import no.uio.inf5750.wsclient.model.Dataset;
import no.uio.inf5750.wsclient.model.OrganisationUnit;
import no.uio.inf5750.wsclient.model.Period;

public class MockupDatasetDAO implements DatasetDAO {

    private Vector datasets;
    private Dataset dataset;

    public MockupDatasetDAO() {
        datasets = new Vector();
        for (int i = 0; i < 10; ++i) {
            Dataset dataset = new Dataset();
            dataset.setName("dataset name" + String.valueOf(i));
            datasets.addElement(dataset);
        }

        Vector elements = new Vector();
        Vector values = new Vector();
        DataElement el;
        DataValue val;

        el = new DataElement();
        el.setName("Element 1 (str)");
        el.setType("string");
        elements.addElement(el);

        el = new DataElement();
        el.setName("Element 2 (str with value)");
        el.setType("string");
        elements.addElement(el);
        val = new DataValue();
        val.setValue("abc");
        val.setDataElement(el);
        values.addElement(val);

        el = new DataElement();
        el.setName("Element 3 (int)");
        el.setType("int");
        elements.addElement(el);

        el = new DataElement();
        el.setName("Element 4 (int with value)");
        el.setType("int");
        elements.addElement(el);
        val = new DataValue();
        val.setValue("123");
        val.setDataElement(el);
        values.addElement(val);

        el = new DataElement();
        el.setName("Element 5 (bool)");
        el.setType("bool");
        elements.addElement(el);

        el = new DataElement();
        el.setName("Element 6 (bool with value)");
        el.setType("bool");
        elements.addElement(el);
        val = new DataValue();
        val.setValue("1");
        val.setDataElement(el);
        values.addElement(val);

        dataset = new Dataset();
        dataset.setId(99);
        dataset.setName("Dataset99");
        dataset.setDataElements(elements);
        dataset.setDataValues(values);

    }
    public Vector listDatasets(OrganisationUnit orgUnit) {

        return datasets;
    }

    public Dataset getDataset(OrganisationUnit orgUnit, Period period, Dataset dataset) {
        System.out.println("Hello");
        System.out.println(this.dataset == null);
        return this.dataset;
    }

    public void saveDataset(Dataset dataset) {
        // TODO Auto-generated method stub

    }

}
